<?php
	$path_one = 'admin/admin_system';
	$path_two = 'admin/admin_module';
	$filename = 'admin/admin_module_list';
	require_once("header.php");
	require_once("admin_comm.php");

	//传过来修改的id
	$id = request('id',false,true);

	if($id){
		$row = admin_fun_find_module($id);
		$row = $row[0];
		$selected[$row['parent_id']] = "selected='selected'";
	}

	if(!$module_level){
		$module_level = admin_fun_module_all_level();
	}
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main'],
		js:['city_area', 'html'],
		skincss:['list']
	});
	$(document).ready(function(){

		var form_obj=$("#form1").Validform({
		   tiptype: function(msg, o, cssctl){
			   if(!o.obj.is("form")){
				   var obj = o.obj.parent("td").find('tt');
				   cssctl(obj, o.type);
				   obj.text(msg);
			   }
		   },
		   postonce:true,
		   ajaxPost:true,
		   callback:function (data){
				dialog.finish({
					content:data.msgs,
					success:data.state,
					/*timeout:10000000,*/
					callback:function (){
						if(data.state){
							window.location.href='/admin/admin_module_list';
							return ;
						}
						window.location.reload();
					}
				})
		   }
		})
	})

</script>
</head>
<body>
<div class="position_nav">你所在的当前位置：<?php echo $path_str;?> &gt; <?php echo $row['id']?'修改/查看权限':'添加权限' ;?></div>
		<div class="main">
		<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="admin/add_module">
			<input type="hidden" name="id" value="<?php echo $row['id'];?>">
			<table  cellpadding="0" width="100%" cellspacing="1" border="0" class="table table_text">
				<tr>
					<td width="12%" height="35" class="left">功能权限组：</td>
					<td width="88%">
						<select name="parent_id">
							<option value="0">作为顶级</option>
							<?php
							if($module_level){
								foreach($module_level as $k=>$v){
							?>
							<option value="<?php echo $v['id'];?>" <?php echo $selected[$v['id']];?>><?php echo $v['content'];?></option>
								<?php
								if($v['child']){
									foreach($v['child'] as $k2=>$v2){
								?>
								<option value="<?php echo $v2['id'];?>"<?php echo $selected[$v2['id']];?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $v2['content'];?></option>
								<?php
									}
								}

								}
							}
							?>
						</select>

					</td>
				</tr>
				<tr>
					<td height="35" class="left">权限名称：</td>
					<td>
						<input type="text" name="content" class="w260" id="content" value="<?php echo $row['content'];?>" datatype="*1-100" errormsg="权限名称不能超过100个字" nullmsg="权限名称不能为空">
						<tt></tt>
					</td>
				</tr>
				<tr>
					<td height="35" class="left">文件路径：</td>
					<td>
						<input type="text" class="w260" name="file" value="<?php echo $row['file'];?>" datatype="*1-50" errormsg="文件路径不能超过50个字" nullmsg="文件路径不能为空" />
						<tt></tt>
					</td>
				</tr>
				<tr>
					<td height="35" class="left">排序：</td>
					<td>
						<input type="text" name="sort" class="w260" value="<?php echo $row['sort']?$row['sort']:0;?>" datatype="n" errormsg="请填写一个整数"><span class="comment">排序值越小越靠前</span>
						<tt></tt>
					</td>
				</tr>
				<tr>
					<td height="35" class="left">状态：</td>
					<td>
						<label><input <?php echo $row['state']?'':'checked="checked"' ?> type="radio" class="noborder" name="state" value="0" />显示</label>
						<label><input <?php echo $row['state']?'checked="checked"':'' ?> type="radio" class="noborder" name="state" value="1" />隐藏</label>
					</td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input class="button1" type="submit" value="<?php echo $row['id']?'修改':'添加' ;?>">
					</td>
				</tr>

			</table>
			</form>
		</div>
	</div>
</body>
</html>
